
import java.lang.reflect.Field;

public class reflection {
    public static void main(String[] args) {
        //test1();
        test2();
    }
    static void test1(){
        printClassInfo("".getClass());
        printClassInfo(Runnable.class);
        printClassInfo(java.time.Month.class);
        printClassInfo(String[].class);
        printClassInfo(int.class);
    }
    static void test2(){
        try{
            Field f = String.class.getDeclaredField("value");
            System.out.println(f.getName());
            System.out.println(f.getType());
        }
        catch(NoSuchFieldException nsfe){
            throw new RuntimeException();
        }
        
    }
    static void printClassInfo(Class cls) {
        System.out.println("Class name: " + cls.getName());
        System.out.println("Simple name: " + cls.getSimpleName());
        if (cls.getPackage() != null) {
            System.out.println("Package name: " + cls.getPackage().getName());
        }
        System.out.println("is interface: " + cls.isInterface());
        System.out.println("is enum: " + cls.isEnum());
        System.out.println("is array: " + cls.isArray());
        System.out.println("is primitive: " + cls.isPrimitive());
    }
}
